<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div>
    <el-form ref="form" :model="sortid" :rules="rules" label-width="100px" id="mvcfm">
      <div class="form-unit">
        <span class="mvc-title-left"> 选择分类 </span>
      </div>
      <el-table :data="sortid">
        <el-table-column label="分类名称" prop="sort_id">
          <template slot-scope="scope">
            <el-link @click="gotoPage('/crm/sale/DistributionAddRelationship?category_id='+emt.map['sort_id']+'&CMID='+emt.map['sort_id']+''+vueparams+'')" type='primary'>{{scope.row.sort_name}}</el-link>
          </template>
        </el-table-column>
      </el-table>
      <div class="form-unit">
        <span class="mvc-title-left"> 选择客户 </span>
      </div>
      <el-table :data="client_list">
        <el-table-column label="操作" align="center" width='100' type=''>
          <template slot-scope="scope">
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>
                  <el-link @click="gotoPage(''+vueparams+'')">查看明细</el-link>
                </el-dropdown-item>
                <el-dropdown-item>
                  <el-link @click="gotoPage(''+vueparams+'')">查看联系人明细</el-link>
                </el-dropdown-item>
                <el-dropdown-item>
                  <el-link @click="popSelectUP('')">选择上级客户</el-link>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
        <el-table-column label="客户名称" prop="">
          <template slot-scope="scope">
            <el-link @click="gotoPage('/crm/sale/SelectUP?CMID3='+emt.map['client_id']+'&category_id=-1'+vueparams+'')" type='primary'>{{scope.row.client_name}}</el-link>
          </template>
        </el-table-column>
        <el-table-column label="姓名" prop="">
        </el-table-column>
        <el-table-column label="状态" prop="">
        </el-table-column>
        <el-table-column label="归属于" prop="">
        </el-table-column>
        <el-table-column label="已输入时间" prop="">
        </el-table-column>
      </el-table>
      <el-button @click="$parent.$parent.popDistributionAddRelationship('')" type='primary' size="mini">核对所有项目</el-button>
      <el-button @click="$parent.$parent.popDistributionAddRelationship('')" type='primary' size="mini">清除所有项目</el-button>
      <el-button @click="$parent.$parent.popDistributionAddRelationship('&category_id='+cate.sort_parent+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回上级</el-button>
    </el-form>
    <el-dialog :visible.sync="SelectUPVisible" append-to-body>
      <SelectUP v-if="SelectUPVisible" ref="SelectUP" :popparams="popparams"> </SelectUP>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import SelectUP from "@/views/crm/sale/SelectUP";
  export default {
    name: 'DistributionAddRelationship',
    components: {
      SelectUP,
    },
    props: ['popparams'],
    data() {
      return {
        SelectUPVisible: false,
        SelectUPValue: null,
        SelectUPDesc: null,
        vueparams: this.getVUEParams(""),
        sortid: [],
        client_list: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/crm/sale/DistributionAddRelationship/distributionAddRelationship?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      popSelectUP(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.SelectUPVisible = !this.SelectUPVisible;
      },
    },
  }
</script>
